package com.example.drug.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @ClassName RxOrderMapper
 * @Author wengjt
 * @Date 2021/4/918:43
 * @Description
 **/



public interface RxOrderMapper {

    @Select("select drug_info_nvarchar as DrugInfo,does_int as Does,day_count_int as DayCount,avoid_nvarchar as Avoid,use_time_nvarchar as UseTime,cook_nvarchar as Cook,total_does_int as TotalDoes,med_way_nvarchar as MedWay"
            +" from order_rx_info where rx_order_no_nvarchar = #{RxOrderNO}")
    List<Map<String, Object>> selectzRxInfoList(@Param("RxOrderNO") String RxOrderNO);

    @Select("select drug_name_nvarchar as DrugName, spec_nvarchar as Spec, num_int as Num, CONCAT(med_way_nvarchar , \"；每日\" , freq_nvarchar , \"；\" , does_int , does_unit_nvarchar , \"/次；\" , day_int , \"天\") as Suggest, remark_nvarchar as Remark"
            +" from order_rx_drugs where rx_order_no_nvarchar = #{RxOrderNO}")
    List<Map<String, Object>> selectxRxInfoList(@Param("RxOrderNO") String RxOrderNO);

    @Select("select a.dc_id_bigint, a.receive_time_datetime, a.order_no_nvarchar, b.allergy_nvarchar, b.past_disease_nvarchar from order_main a"
            +" inner join order_patients_info b on a.patients_info_id_bigint = b.id_bigint"
            +" where a.system_status_tinyint = 2 and a.oc_status_tinyint != 0 and b.pid_bigint = #{pid}"
            +" order by a.create_time_datetime desc"
            +" limit 1")
    Map<String, Object> selectLastOrder(@Param("pid") long pid);
}
